<template>
    <div class="bg-color">
        <div class="login-container">
            <div>
                <div class="gradient-font"><span style="display: inline-block;width: 20px;"></span>{{ title }}</div>
            </div>
            <div>
                <div class="login-title">用户登录</div>
                <el-form ref="loginForm" :model="formData" :rules="rules">
                    <el-form-item prop="account">
                        <el-input :prefix-icon="User" size="large" v-model="formData.account"
                            placeholder="登录账号"></el-input>
                    </el-form-item>
                    <el-form-item prop="password">
                        <el-input :prefix-icon="Unlock" size="large" v-model="formData.password"
                            placeholder="登录密码"></el-input>
                    </el-form-item>
                    <el-form-item prop="code">
                        <el-col :span="16">
                            <el-input :prefix-icon="View" size="large" v-model="formData.code"
                                placeholder="验证码"></el-input>
                        </el-col>
                        <el-col :span="8">
                            <el-image style="width: 77px; height: 36px" :src="code" fit="cover"></el-image>
                        </el-col>
                    </el-form-item>
                    <el-form-item>
                        <el-button type="primary" size="large" @click="onSubmit" style="width: 100%;">登录</el-button>
                    </el-form-item>
                </el-form>
            </div>

        </div>
    </div>
</template>

<script lang="ts" setup>
import utils from "@/utils/index.js"
import { ref, reactive } from "vue"
import { useRouter } from 'vue-router'
const router = useRouter()

const title = import.meta.env.VITE_BASE_TITLE
const formData = reactive({
    account: '',
    password: '',
    code: ''
})
const code = ref(utils.getAssetsFile('code.jpg'))
import { User, Unlock, View } from '@element-plus/icons-vue'
const rules = ref({
    account: [
        { required: true, message: '登录账号不能为空', trigger: 'blur' }
    ],
    password: [
        { required: true, message: '密码不能为空', trigger: 'blur' }
    ],
    code: [
        { required: true, message: '验证码不能为空', trigger: 'blur' }
    ],

})
const loginForm = ref(null)
const onSubmit = () => {
  router.push('/home')
    // loginForm.value.validate((valid) => {
  //     if (valid) {
  //         router.push('/home')
  //
  //     } else {
  //         console.log('error submit!!');
  //         return false;
  //     }
  // });
}

</script>

<style lang="scss" scoped>
.bg-color {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: url('@/assets/images/loginbg.png') no-repeat center center / cover;
}

.login-container {
    width: 52.083vw;
    height: 33.75vw;
    border-radius: 1.042vw;
    overflow: hidden;
    display: flex;
  .gradient-font{
    text-align: center;
  }


    >div:first-child {
        width: 25vw;
        height: 100%;
        background: url('@/assets/images/loginleft.png') no-repeat center center / cover;

        >div:first-child {
            width: 100%;
            font-size: 1.71875vw;
            font-weight: bold;
            margin-top: 20%;
            padding-left: 15px;
        }
    }

    >div:last-child {
        width: calc(100% - 25vw);
        height: 100%;
        box-sizing: border-box;
        background-color: #FFFFFF;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
    }
}

.login-title {
    padding-bottom: 40px;
    font-size: 1.458vw;
    line-height: 1;
    color: #3b77e3;
    text-align: center;
}
</style>
